set (MEDIAFOUNDATION_FOUND "NO")
set (MEDIAFOUNDATION_LIBRARIES "")

if (WIN32)
	set (HDR_SEARCH_PATHS
        "C:/Program Files/Microsoft SDKs/Windows/v7.1/Include"
	)
	set (LIB_SEARCH_PATHS
        "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib"
	)
endif (WIN32)

find_path (MEDIAFOUNDATION_INCLUDE_DIR mfapi.h PATHS ${HDR_SEARCH_PATHS})

set (MEDIAFOUNDATION_LIBS
	mfreadwrite
	mfplat
	mf
)

foreach (MEDIAFOUNDATION_LIB ${MEDIAFOUNDATION_LIBS})
	string (TOUPPER ${MEDIAFOUNDATION_LIB} MEDIAFOUNDATION_LIB_VAR)

	if (NOT ${MEDIAFOUNDATION_LIB_VAR}_FOUND)
		find_library (${MEDIAFOUNDATION_LIB_VAR}_LIBRARY NAMES ${MEDIAFOUNDATION_LIB} PATHS ${LIB_SEARCH_PATHS})
		if (${MEDIAFOUNDATION_LIB_VAR}_LIBRARY)
			set (MEDIAFOUNDATION_LIBRARIES ${MEDIAFOUNDATION_LIBRARIES} ${${MEDIAFOUNDATION_LIB_VAR}_LIBRARY})
		endif (${MEDIAFOUNDATION_LIB_VAR}_LIBRARY)
		mark_as_advanced (${MEDIAFOUNDATION_LIB_VAR}_LIBRARY)
	endif (NOT ${MEDIAFOUNDATION_LIB_VAR}_FOUND)
endforeach (MEDIAFOUNDATION_LIB)

mark_as_advanced (MEDIAFOUNDATION_INCLUDE_DIR MEDIAFOUNDATION_LIBRARIES)

set (MEDIAFOUNDATION_INCLUDE_DIR ${MEDIAFOUNDATION_INCLUDE_DIR} CACHE PATH "MediaFoundation include folder" FORCE)
set (MEDIAFOUNDATION_LIBRARIES ${MEDIAFOUNDATION_LIBRARIES} CACHE FILEPATH "All MediaFoundation related libraries" FORCE)

if (MEDIAFOUNDATION_INCLUDE_DIR AND MEDIAFOUNDATION_LIBRARIES)
	set (MEDIAFOUNDATION_FOUND "YES")
endif (MEDIAFOUNDATION_INCLUDE_DIR AND MEDIAFOUNDATION_LIBRARIES)

if (MEDIAFOUNDATION_FOUND)
	if (NOT MEDIAFOUNDATION_FIND_QUITELY)
		message (STATUS "MediaFoundation found")
	endif (NOT MEDIAFOUNDATION_FIND_QUITELY)
else (MEDIAFOUNDATION_FOUND)
	if (MEDIAFOUNDATION_FIND_REQUIRED)
		message (FATAL_ERROR "Could NOT find MediaFoundation")
	endif (MEDIAFOUNDATION_FIND_REQUIRED)
	if (NOT MEDIAFOUNDATION_FIND_QUITELY)
		message (STATUS "Could NOT find MediaFoundation")
	endif (NOT MEDIAFOUNDATION_FIND_QUITELY)
endif (MEDIAFOUNDATION_FOUND)

